Skip to main content

seek

Type

command

Summary

Locates a position in a file, to be used by the read from file and write to file commands.

Syntax

seek {to | rel[ative]} <byteNumber> in file <filePath>

Description

Use the seek command to prepare to read from or write to an open file at a specific position in the file.

The next read from file or write to file command will start reading or writing at the position specified by the seek command.

Theform sets the file position to byteNumber bytes from the start of the file. Theform sets the file position to byteNumber bytes from the current position. The position is set by either a previous seek command, or a read from file or write to file command.

Parameters

NameTypeDescription

byteNumber

integer

An integer representing the position in the file.

filePath

The filePath specifies the name and location of the file you want to seek in. It must be the same as the path you used with the open file command. The filePath is case-sensitive, even on platforms where file names are not case-sensitive.

Examples

seek to 100 in file "test.txt"
seek relative -10 in file "test.txt"
put specialFolderPath("desktop")  & "/test.txt" into tFile
open file tFile for write
write "123456789--" to file tFile
seek to 9 in file tFile
write "10" to file tFile
close file tFile

command: close file, read from file, write to file

glossary: command, byte

keyword: file, relative

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?